package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

import play.data.validation.Required;
import play.db.jpa.Model;

/**
 * Invitation Entity, Used to create the invitation class that is used by any
 * user inviting another user
 * 
 * @author Mai Selwanes
 */
@Entity
public class Invitation extends Model {

	/**
	 * the receiver of the invitation
	 * 
	 * @author Mai Selwanes
	 */
	@Required
	@ManyToOne
	public User receiver;
	/**
	 * the message that is stated in the invitation
	 * 
	 * @author Mai Selwanes
	 */
	@Required
	public String message;
	/**
	 * the id of the entity to which the receiver is invited
	 * 
	 * @author Mai Selwanes
	 */
	@Required
	public Long entityOrOrgId;
	

	/**
	 * there can be several types for the invitations. Accordingly the rendering
	 * in the views will take place, for example: organizer ideaDeveloper
	 * 
	 * @author Mai Selwanes
	 */
	// please whoever will use this class, shall add the types of his/her
	// invites
	@Required
	public String type;
	
     
	/**
	 * 
	 * Empty constructor
	 * 
	 * @author Mai Selwanes
	 */
	public Invitation() {
	};

	/**
	 * Default constructor
	 * 
	 * @param receiver
	 *            the receiver of the invitation
	 * @param message
	 *            the message that is stated in the invitation
	 * @param type
	 *            the type of the invitation
	 * @author Mai Selwanes
	 * 
	 */
	public Invitation(User receiver, String message, String type, Long entityOrOrgId) {
		this.receiver = receiver;
		this.message = message;
		this.type = type;
		this.entityOrOrgId = entityOrOrgId;

	}
	
	

	/**
	 * acceptInvitatin takes accpet , sender, receiver, org as parameters and
	 * responds to the invitation if accepted or rejetced
	 * 
	 * 
	 * 
	 * author Noha wafa
	 * 
	 */
	/*
	 * public void acceptInvitatin(boolean accept, User sender ,User receiver,
	 * Organization org) { if(accept==true) { String
	 * usertype=Permission.userPermissionInOrganization(receiver.id, org.id);
	 * if(usertype=="ideadeveloper") usertype="organizer"; this.delete();
	 * 
	 * } else
	 * 
	 * this.delete();
	 * 
	 * }
	 */
}
